package com.jlkf.controller;

import com.jlkf.pojo.DriverTurnover;
import com.jlkf.service.FinanceService;
import com.jlkf.temp.Page;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/finance")
public class FinanceController {

    @Autowired
    private FinanceService financeService;

    //月结算订单
    @RequestMapping(value="/month/orders",method=RequestMethod.GET)
   /* @GetMapping("/month/orders")*/
    @ResponseBody
    public Object monthOrders(DriverTurnover month, Page page){
        return financeService.monthOrders(month,page);
    }
 
    //周结算订单
    /*@GetMapping("/week/orders")*/
    @RequestMapping(value="/week/orders",method=RequestMethod.GET)
    @ResponseBody
    public Object weekOrders(DriverTurnover week, Page page){
    	Integer type=week.getType();
        //没选周
        if(week != null && week.getRatio() != null){
            week.setMonth(new DateTime().minusDays((new DateTime()).getDayOfWeek()+1+7*week.getRatio()).toDate());
        }else{
            if(week!=null){
                week = new DriverTurnover();
            }
            week.setMonth(new DateTime().minusDays((new DateTime()).getDayOfWeek()+1).toDate());
        }
        week.setType(type);
        return financeService.weekOrders(week,page);
    }

    
    //月订单
   /* @GetMapping("/month/info")*/
    @RequestMapping(value="/month/info")
    @ResponseBody
    public Object monthInfo(DriverTurnover info, Page page){
        return financeService.monthInfo(info,page);
    }
    //周订单
    @RequestMapping(value="/week/info")
   /* @GetMapping("/week/info")*/
    @ResponseBody
    public Object weekInfo(DriverTurnover info, Page page){
        return financeService.weekInfo(info,page);
    }

    //monthlyReportStatistics
}
